<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<link href='http://fonts.googleapis.com/css?family=Archivo+Narrow:400italic,700,700italic,400' rel='stylesheet' type='text/css'/>
    	<link rel="StyleSheet" type="text/css" href="style.css" media="screen" />
        <link rel="StyleSheet" type="text/css" href="search.css" media="screen" />
		<script type="text/javascript" src="js/jquery-1.8.2.min.js">
		</script>
		<script type="text/javascript" src="js/jquery.bgpos.js"></script>
		<script type="text/javascript" src="js/MainMenu.js"></script>
		<script type="text/javascript" src="js/LightBox.js"></script>
        <script type="text/javascript" src="js/validation.js"></script>
		<link rel="StyleSheet" type="text/css" href="MenuStyle.css" media="screen" />
    	<title> Premier Products - Catalogue </title> 
		<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
		<link rel="icon" href="favicon.gif" type="image/gif">
    </head>
	
	<body>
		<div id="header">
			<h1> Premier </h1>
			<h1> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Products </h1>
		</div>
		<div id="content">
			<div id="main">
          		<div id="search">
                    <form action="" method="get" onsubmit="validateSearch(); return false;" >
                        <p>
                        <label for="artist" >Select the artist's name:</label>
                        <select name="artist" >
						<!--- if URl.artist is there select the one the user just selected --->
                            <option value="all">All Artists</option>
                            <option value="AP" <cfif IsDefined("URL.artist") and URL.artist is "AP"> selected="selected" </cfif> 
                                >Annie Potts</option>
                            <option value="HW" <cfif IsDefined("URL.artist") and URL.artist is "HW"> selected="selected" </cfif>
                            	>Herbert Wells</option>
                            <option value="SG" <cfif IsDefined("URL.artist") and URL.artist is "SG"> selected="selected" </cfif>
                            	>Sasha Goods</option>
                        </select>
                        </p>
                        <p>
                        <label for="prodName">Piece name:</label>
                        <input type="text" name="prodName" />
                        </p>
                        <p>
                        <label for="prodPriceMin" >Minimum price:</label>
                        <input type="text" name="prodPriceMin" onfocus="resetField(this,'Please enter a number');" />
                        </p>
                        <p>
                        <label for="prodPriceMax" >Maximum price:</label>
                        <input type="text" name="prodPriceMax" onfocus="resetField(this,'Please enter a number');" />
                        </p>
                        <p>
                        <button type="submit">Search</button>
                    	</p>
                    </form>
                </div>
                <hr />
				<div class="info">
					<h3>
                    <!-- Select the correct title based on URL.artist -->
                     <cfif IsDefined("URL.artist") and URL.artist is not "all">
						<cfif URL.artist is "AP">
                        	Paintings by Annie Potts
                        </cfif>
						<cfif URL.artist is "HW">
                        	Paintings by Herbert Wells
                        </cfif>
						<cfif URL.artist is "SG">
                        	Paintings by Sasha Goods
                        </cfif>                    
                     <cfelse>
                        All Paintings
                     </cfif>
					</h3>
                    <!-- Search CF code -->
					<cfset bAddAND = False>
					<cfif IsDefined("URL.artist") and (URL.artist is not "all"
                            or  URL.prodName is not ""
                            or  URL.prodPriceMin is not ""
                            or  URL.prodPriceMax is not "")>   
                        <cfquery name="getFeatured" datasource="fit1012" username="fit1012" password="fit1012">
                            select * from PP_PARTS where
                            <cfif URL.artist is not "all">
                                ITEM_CLASS = '#URL.artist#'
                                <cfset bAddAND = true>
                            </cfif>
                            <cfif URL.prodName is not "">
								<cfif bAddAND is true>
                                and 
                                </cfif>
                                upper(PART_DESCRIPTION) like upper('%#URL.prodName#%')
                                <cfset bAddAND = true>
                            </cfif>
                            <cfif URL.prodPriceMin is not ""
							and  URL.prodPriceMax is not "">                            	
								<cfif bAddAND is true>
								and 
								</cfif>
								UNIT_PRICE between '#URL.prodPriceMin#' and '#URL.prodPriceMax#'                            
							
							<cfelseif URL.prodPriceMin is not ""
							and URL.prodPriceMax is "">
								<cfif bAddAND is true>
								and 
								</cfif>
								UNIT_PRICE > '#URL.prodPriceMin#'
							<cfelseif URL.prodPriceMin is ""
							and URL.prodPriceMax is not "">
								<cfif bAddAND is true>
								and 
								</cfif>
								UNIT_PRICE < '#URL.prodPriceMax#'
							</cfif>
                        </cfquery>
                    <cfelse>   
                        <cfquery name="getFeatured" datasource="fit1012" username="fit1012" password="fit1012">
                            select * from PP_PARTS
                        </cfquery>
                    </cfif>
                    
                    <!---<table>
                      <tr> <th>Part Number</th> <th>Part Description</th> <th>Item Class</th> <th>Units On Hand</th> <th>Warehouse Number</th> <th>Unit Price</th> </tr>
                      <cfoutput query="getFeatured">  
                      <tr> <td>#PART_NUMBER#</td> <td>#PART_DESCRIPTION#</td> <td>#ITEM_CLASS#</td> <td>#UNITS_ON_HAND#</td> <td>#WAREHOUSE_NUMBER#</td> <td>#UNIT_PRICE#</td> </tr>
                      </cfoutput>
                    </table>--->
                    <div id="catalogue">
                        <cfloop query="getFeatured">
                            <!---<a href="images/<cfoutput>#PART_DESCRIPTION#</cfoutput>.jpg" title="Painting" rel="LightBox" >
							<img src="images/thumbnails/<cfoutput>#PART_DESCRIPTION#</cfoutput>_s.jpg" alt="<cfoutput>#PART_DESCRIPTION#</cfoutput>"/></a>---> 
                            <a href="productPage.cfm?product_id=<cfoutput>#PART_NUMBER#</cfoutput>" title="<cfoutput>#PART_DESCRIPTION#</cfoutput> by <cfoutput>#ITEM_CLASS#</cfoutput>" >
							<img src="images/thumbnails/<cfoutput>#PART_DESCRIPTION#</cfoutput>_s.jpg" alt="<cfoutput>#PART_DESCRIPTION#</cfoutput>"/></a>
                        </cfloop>
                    </div>
                </div>
			</div>
			<div id="navigation">
				<ul>
					<li class="blue"> 
						<a href = "index.cfm"> Home 	</a>
						<p class="subtext">The front page</p>
					</li>
					<li class="red">
						<a href = "catalogue.cfm"> Catalogue	</a>
						<p class="subtext">Our products</p>
					</li>
                    <li class="green">
						<a href = "about.cfm"> About	</a>
						<p class="subtext">All about us</p>
					</li>
				</ul>
			</div>
		</div>
		<div id="footer">
			<p> 2012 &copy; Yati &amp; Nick </p>
		</div>
	</body>
</html>